﻿using System;
using System.Text;

class Dictionary
{
    static void Main()
    {
        //Exercise 14.
        //A dictionary is stored as a sequence of text lines containing words and their explanations. Write a program that enters 
        //a word and translates it by using the dictionary. Sample dictionary:
        //.NET – platform for applications from Microsoft
        //CLR – managed execution environment for .NET
        //namespace – hierarchical organization of classes

        string dictionary = @".NET - platform for applications from Microsoft
                            CLR - managed execution environment for .NET
                            namespace - hierarchical organization of classes";
        Console.Write("Enter a word: ");
        string word = Console.ReadLine();
        //string word = "CLR";
        string[] lines = dictionary.Split('\n');
        bool inDictionary = false;
        for (int i = 0; i < lines.Length; i++)
        {
            string[] definitions = lines[i].Split('-');
            for (int j = 0; j < definitions.Length; j++)
            {
                definitions[j] = definitions[j].Trim();
                if (definitions[j] == word)
                {
                    Console.WriteLine("{0} - {1}", word, definitions[1]);
                    inDictionary = true;
                }                
            }
        }
        if (inDictionary == false)
        {
            Console.WriteLine("The word cannot be found in the dictionary");
        }
       
    }
}

